package logging;

public class Logger {
	public static int OFF = 0;
	public static int FATAL = 1;
	public static int SEVERE = 2;
	public static int WARNING = 3;
	public static int INFO = 4;
	public static int DETAIL = 5;
	public static int TRACE = 6;
	public static int EXTRANEOUS = 7;
	private int badLevel = 3;
	
	public static Logger getInstance() {
		return instance;
	}

	private int logLevel;

	/**
	 * Single instance created upon class loading.
	 */
	private static final Logger instance = new Logger();

	/**
	 * Private constructor prevents construction outside this class.
	 */
	private Logger() {
		logLevel = Logger.TRACE;
	}

	public void log(int level, String message){
		if(level <= logLevel){
			if(level <= badLevel){
				System.err.println(message);
			} else {
				System.out.println(message);
			}
		}
	}
	
	public int getLogLevel() {
		return logLevel;
	}

	public void setLogLevel(int logLevel) {
		if(logLevel >= 0 && logLevel <= 7)
			this.logLevel = logLevel;
	}
}
